package News.servlet;

import News.service.Server;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import java.io.IOException;
import java.io.PrintWriter;

public class updateStateServlet extends HTTPServlet{
    protected void doGet(HttpServletRequest rq, HttpServletResponse rs) throws IOException, ServletException {
        String msgId=(String)rq.getParameter("msgId");
        String sql="update WSQ.user_msg set state=1 where msgId="+msgId+" and is_delete='1'";
        String select="SELECT `content` FROM WSQ.user_msg where msgId="+msgId;
        Server s=new Server();
        int i=0;
        i=s.update(sql);
        String content=s.selectUsername(select);
        JOptionPane.showMessageDialog(null,content);
        boolean judge=false;
        if(i>0){
            judge=true;
        }else{
            judge=false;
        }
        rs.setContentType("text/html;charset=UTF-8");
        PrintWriter pw=rs.getWriter();
        pw.print(judge);
        pw.flush();
        pw.close();
    }
}
